<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>理解视差效果原理</title>
    <style>
         body {
             margin:0;
             padding:0;
         }

        div {
            width:100%;
            height:500px;
        }

        div:first-child {
            background: url("images/1.jpg") no-repeat center;
            /* 设置图片尺寸的属性 */
            background-size: cover;
            /* cover:图片自适应完全铺满 */
        }

         div:last-child {
             background: url("images/2.jpg") no-repeat center / cover;
             /*background-attachment: scroll;*/
             background-attachment: fixed;
         }
    </style>
</head>
<body>
    <div class=""></div>
    <div></div>
</body>
</html>